﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;

namespace SkypeBotCore
{
    public static class XMLManager
    {
        #region Serialize

        public static void Serialize(object objData, Type objType, string strOutputPath)
        {
            using (XmlWriter mobjWriter = new XmlTextWriter(strOutputPath, Encoding.Unicode))
                {
                    XmlSerializer mobjSerializer = new XmlSerializer(objType);
                    mobjSerializer.Serialize(mobjWriter, objData);
                }

        }
        #endregion

        #region Deserialize
        public static object Deserialize(Type objType,string strInputPath)
        {
            object mobjOutputObject = null;

            using (XmlReader mobjReader = new XmlTextReader(strInputPath))
            {
                XmlSerializer mobjSerializer = new XmlSerializer(objType);
                mobjOutputObject = mobjSerializer.Deserialize(mobjReader);
            }
            return mobjOutputObject;
        }
        #endregion

    }
}
